package com.leetcode.LC;

public class LC479 {
    public int findComplement(int num) {

        int rs=0;
        StringBuilder stringBuilder = new StringBuilder(Integer.toBinaryString(num));
        String s = stringBuilder.reverse().toString();
        System.out.println(s);
        for (int i = 0; i < s.length(); i++) {
            rs+=(s.charAt(i)=='0'?1:0)*Math.pow(2,i);
        }
        return rs;
    }

    public static void main(String[] args) {
        System.out.println(new LC479().findComplement(5));
    }
}
